import request from '../../utils/request';
import store from '../../store/index';

// 发送聊天消息
export function sendChatMessage(message, color) {
  return request.post('sendMsgController/msgGo6', {
    content: message,
    color,
    splid: store.state.live.liveId,
  });
}

// 获取聊天记录
export function getChatMessage() {
  return request.get(`wxScan/getMsgInfo?splid=${store.state.live.liveId}&num=1&size=30`);
}

// 发礼物的广播
export function sendGiftMessage(content) {
  return request.post('sendMsgController/liwuGo6', {
    splid: store.state.live.liveId,
    liwuId: store.state.app.currentGiftType,
    content,
  });
}

// 发送照片礼物的广播
export function sendPhotoGiftMessage(content, imgUrl) {
  const choosedPhotoType = store.state.live.photoTypeList.find((item) => item.giftId === store.state.app.currentPhotoType);
  return request.post('sendMsgController/liwuGo6', {
    splid: store.state.live.liveId,
    liwuId: store.state.app.currentPhotoType,
    content,
    tpUrl: imgUrl,
    times: choosedPhotoType.time,
  });
}

// 发送照片墙礼物的广播
export function sendPhotoWallGiftMessage(imgUrl) {
  return request.post('sendMsgController/liwuGo6', {
    splid: store.state.live.liveId,
    liwuId: 'Miao_PhotoWall',
    content: '爱心照片墙',
    tpUrl: imgUrl,
    times: 10,
  });
}

// 发送霸气弹幕礼物广播
export function sendDanmuGiftMessage(content) {
  return request.post('sendMsgController/liwuGo6', {
    splid: store.state.live.liveId,
    liwuId: store.state.app.currentDanmuType,
    content,
  });
}

// 发送超级弹幕礼物广播
export function sendSuperDanmuGiftMessage(content, giftId) {
  return request.post('sendMsgController/liwuGo6', {
    splid: store.state.live.liveId,
    liwuId: giftId || store.state.app.currentSuperDanmuType,
    content,
  });
}

// 发送霸屏礼物广播
export function sendBapinGiftMessage(content) {
  return request.post('sendMsgController/liwuGo6', {
    splid: store.state.live.liveId,
    liwuId: store.state.app.currentBapinType,
    content,
  });
}

// 发送广播
export function sendBroasCast(paramObj) {
  return request.post('sendMsgController/duxin6', {
    ykq_info: paramObj.c,
    splid: store.state.live.liveId,
  });
}
